<template>
	<div>
		<div>
			<Row>
				<Col class="p-2" :xs="24" :sm="24" :md="12" :lg="8" :xl="6" :xxl="6">
				<div class="d-flex justify-content-between align-items-center shadow rounded p-2">
					<span>字典编码</span>
					<Input class="w-75" v-model="dict.code" placeholder="请输入字典编码"></Input>
				</div>
				</Col>
				<Col class="p-2" :xs="24" :sm="24" :md="12" :lg="8" :xl="6" :xxl="6">
				<div class="d-flex justify-content-between align-items-center shadow rounded p-2">
					<span>字典键值</span>
					<Input class="w-75" v-model="dict.value" placeholder="请输入字典键值" />
				</div>
				</Col>
				<Col class="p-2" :xs="24" :sm="24" :md="12" :lg="8" :xl="6" :xxl="6">
				<div class="d-flex justify-content-between align-items-center shadow rounded p-2">
					<span>字典类型</span>
					<Input class="w-75" v-model="dict.type" placeholder="请输入字典类型" />
				</div>
				</Col>

				<Col class="p-2" :xs="24" :sm="24" :md="12" :lg="8" :xl="6" :xxl="6">
				<div class="d-flex justify-content-between align-items-center shadow rounded p-2">
					<span>排序</span>
					<Input class="w-75" v-model="dict.sort" placeholder="请输入排序" />
				</div>
				</Col>
				
			</Row>



		</div>
		<div class="p-2 d-flex justify-content-end">
		  <Button @click="submit" type="primary">提交</Button>
		</div>
		
	</div>

</template>

<script>
	export default {
		props: {
			params: {
				type: Object,
				default: undefined,
			}
		},
		data: function() {
			return {
				dictCode:'',
				dict: {
					code: '',
					value: '',
					type: '',
					sort: '',
					
				},
			};
		},

		methods: {
			init: function() {
			this.dict.code = this.params.code;
			console.log(this.dict.code)
				this.http.get({
					url: "/dict/info",
					param: {
						code: this.dict.code
					}
				}).then(data => {
					this.dict = data
				})
			},



			submit: function() {
				this.http.put({
					url: "/dict/info",
					data: {
						dict:this.dict,
						dictCode: this.dictCode
					}
				}).then(data => {
					this.message.info("添加成功");
					this.$router.detail.close();
					this.$tabs.refresh('/dict')
				});
			},
		},
		created: function() {
			this.dict.code = this.params.code;
			this.dictCode= this.params.code;
			this.init();
		}


	}
</script>

<style>
</style>